package com.bw.controller;

import com.bw.domain.Sugar;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/list")
    public Map t1(){
        List<Sugar> list=sugarService.get1();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("/llist")
    public Map t2(){
        Map map=new HashMap<>();
        double total=sugarService.get2();
        map.put("status",0);
        map.put("data",total);
        return map;
    }

    @RequestMapping("/list3")
    public Map t3(){
        List<Sugar> list=sugarService.get3();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("/list4")
    public Map t4(){
        List<Sugar> list=sugarService.get4();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("/list5")
    public String t5(){
        List<Sugar> list=sugarService.get5();
        List<String> list1=new ArrayList<>();
        list1.add("spu名称");
        list1.add("金额");
        return SugarUtil.getTablePlayData(list1,list);
    }


}
